<%--
  Created by IntelliJ IDEA.
  User: 岩蔷薇没有毒
  Date: 2020/9/25
  Time: 10:50
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<script src="../js/jquery-3.5.1.js"></script>
<script src=""></script>
<script src="../js/bootstrap.js"></script>
<link rel="stylesheet" href="../css/bootstrap.css">
<html>
<head>
    <title>Title</title>
</head>
<body>
<h1>文件上传</h1>
<%--<form action="fileUpload.do" enctype="multipart/form-data" method="post">--%>
<form class="form-horizontal" id="goods" action="../goods.do?method=upload" enctype="multipart/form-data" method="post">
    <input type="hidden" id="method" value="addGoods">
    <h3>请填写商品信息：</h3>
    <div class="form-group">
        <label for="inputEmail3" class="col-sm-2 control-label">商品名称</label>
        <div class="col-sm-10">
            <input type="text" class="form-control" name="name" id="name" placeholder="请输入">
        </div>
    </div>

    <div class="form-group">
        <label for="inputEmail3" class="col-sm-2 control-label">商品分类</label>
        <div class="col-sm-10">
            <select class="form-control" name="category" id="category">
                <option>请选择</option>
            </select>
        </div>
    </div>

    <div class="form-group">
        <label for="inputEmail3" class="col-sm-2 control-label">颜色</label>
        <div class="col-sm-10">
            <input type="text" class="form-control" name="color" id="color" placeholder="请输入">
        </div>
    </div>

    <div class="form-group">
        <label for="inputEmail3" class="col-sm-2 control-label">价格</label>
        <div class="col-sm-10">
            <input type="text" class="form-control" name="price" id="price" placeholder="请输入">
        </div>
    </div>

    <div class="form-group">
        <label for="inputEmail3" class="col-sm-2 control-label">库存</label>
        <div class="col-sm-10">
            <input type="text" class="form-control" name="inventory" id="inventory" placeholder="请输入">
        </div>
    </div>

    <div class="form-group">
        <label for="inputEmail3" class="col-sm-2 control-label">图片上传</label>
        <div class="col-sm-10">
            <input type="file" name="file" id="picture">
        </div>
    </div>

    <div class="form-group">
        <label for="inputEmail3" class="col-sm-2 control-label">描述</label>
        <div class="col-sm-10">
            <textarea class="form-control" name="description" id="description" rows="3"></textarea>
        </div>
    </div>


    <div class="form-group" id="submit">
        <div class="col-sm-offset-2 col-sm-10">
            <button type="submit" class="btn btn-success">提交</button>
        </div>
    </div>
</form>
</body>
<script>


    // function submitForm() {
    //     // jquery 表单提交
    //     $("#upload").ajaxSubmit(function(message) {
    //         // 对于表单提交成功后处理，message为表单正常提交后返回的内容
    //         console.log(message);
    //     });
    //     return false; // 必须返回false，否则表单会自己再做一次提交操作，并且页面跳转
    // }

    // $(document).ready(function () {
    //     $("#submit").click(function () {
    //         var formData = new FormData($("#goods")[0]);
    //         alert(formData)
    //        $.ajax({
    //            url:"../goods.do",
    //            data:{"method":"upload",formData},
    //            type:"post",
    //            // cache: false,
    //            // processData: false,
    //            // contentType: false,
    //            success:function (result) {
    //                 if (result=='true'){
    //                     alert("成功");
    //                 }else{
    //                     alert("失败");
    //                 }
    //            }
    //        })
    //     })
    // })
</script>
</html>
